package com.shop2cn.iapi.agentproducts.testcase;

import java.awt.Color;
import java.awt.Font;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.EditProductRebateBean;
import com.shop2cn.iapi.agentproducts.parameter.GetProductListBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.shop2cn.iapi.agentproducts.parameter.ProductListDto;
import com.shop2cn.iapi.agentproducts.parameter.SaveSelectionConditionBean;
import com.shop2cn.iapi.agentproducts.service.GetProductListCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godfreightmgr.parameter.CreateFreightTemplateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.createDepotBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.setConditionMarkupConfigBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.iapi.productsynces.parameter.es.EsGodProduct;
import com.ymatou.iapi.productsynces.service.ESGodsearchCall;
import com.ymatou.iapi.sellerproduct.parameter.ESsearchBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallService;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.GodfreightmgrService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.model.godmch.mch_depot_info;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.database.sqlwapper.godfreight.freight_templateWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.FontImage;
import com.ymttest.utils.TestDataManager;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 我的商品列表 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetProductList {
	private static GetProductListBean getproductlistBean;
	private static GetProductListCall getproductlistCall;
	private static YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
	private static YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
	// 渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";
	// 渠道商->代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	// 渠道商->代理商2
	private static int agentUserId2 = AgentUsers.agentUserId2;
	private static String agentUserName2 = "NickautoTest";

	// vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	// vip渠道->代理
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	// vip渠道->代理->代理
	private static int vipAgentUserId2 = AgentUsers.vipAgentUserId2;
	private static String vipAgentUserName2 = "NickautoTest";

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("我的商品列表");
	}

	@Before
	public void caseUp() {
		getproductlistBean = new GetProductListBean();
		getproductlistCall = new GetProductListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getproductlistCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_01() {
		Logger.start(true, "渠道商获取自采商品，上架商品列表");
		try {
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(rootUserId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(0);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(p -> {
				AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(p.getProductId());
				Logger.verifyEquals(1, agentProductPo.getStatus(), "验证商品是上架状态");
			});
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_02() {
		Logger.start(true, "渠道商获取自采商品，下架商品列表");
		try {
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(rootUserId);
			getproductlistBean.setStatus(2);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(0);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(p -> {
				AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(p.getProductId());
				Logger.verifyEquals(2, agentProductPo.getStatus(), "验证商品是下架状态");
			});
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_03() {
		Logger.start(true, "渠道商获取自采商品，售罄商品列表");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			// 库存售罄
			ymtCatalogsIWapper.updatestocknumByProductID(0, productId);
			
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(rootUserId);
			getproductlistBean.setStatus(3);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(0);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(p -> {
				p.getCatalogList().forEach(x -> {
					try {
						YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(x.getCatalogId());
						Logger.verifyEquals(0, ymtCatalogsI.getiNum(), "验证商品库存为0");
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				});
			});
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_04() {
		Logger.start(true, "渠道商获取自采商品，待完善商品列表");
		try {
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(rootUserId);
			getproductlistBean.setStatus(4);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(0);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			// AgentProductCallService.checkProductList(getproductlistBean,
			// productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_GetProductList_09() {
		Logger.start(true, "渠道商获取自采商品，全部商品");
		try {
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(rootUserId);
			getproductlistBean.setStatus(0);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_06() {
		Logger.start(true, "代理商获取代理商品，下架商品列表");
		try {
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setStatus(2);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_07() {
		Logger.start(true, "代理商获取代理商品，售罄列表，获取成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
			ymtCatalogsIWapper.updatestocknumByProductID(0, productId);
			Thread.sleep(3000);
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setStatus(3);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_08() {
		Logger.start(true, "代理商获取代理商品，待完善");
		try {
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setStatus(4);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_16() {
		Logger.start(true, "渠道商获取商品，库存不足商品列表");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ymtCatalogsIWapper.updatestocknumByProductID(8, productId);

			getproductlistBean.setUserId(vipRootUserId);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_15() {
		Logger.start(true, "代理商获取代理商品，库存不足商品列表");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ymtCatalogsIWapper.updatestocknumByProductID(8, productId);

			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductListNotsku(getproductlistBean, productListDtoList);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_17() {
		Logger.start(true, "代理获取代理上架商品");
		try {
			getproductlistBean.setUserId(agentUserId1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			Thread.sleep(5000);
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
			System.out.println(JSONObject.fromObject(getproductlistBean).toString());
			System.out.println(JSONArray.fromObject(productListDtoList).toString());
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_18() {
		Logger.start(true, "代理商获取渠道商自采商品，获取失败");
		try {
			getproductlistBean.setUserId(vipAgentUserId2);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(0);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(true, productListDtoList.size() == 0, "验证返回结果为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_19() {
		Logger.start(true, "根据商品标题来获取商品列表");
		try {
			getproductlistBean.setUserId(vipAgentUserId2);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(0);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setTitle("God");
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_20() {
		Logger.start(true, "渠道商发布商品，带运费模板，获取商品详细");
		try {
			createmchBean createmchBean = GodmchManageCallService.InitcreatemchBeanForChannel();
			GodmchManageCallService.createmchCallForChannel(createmchBean);

			CreateFreightTemplateBean createFreightTemplateBean = GodfreightmgrService
					.initCreateFreightTemplate(createmchBean.getMchId(), 1, 2);
			String telId = GodfreightmgrService.CreateFreightTemplate(createFreightTemplateBean);

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService
					.initAddAgentProduct(createmchBean.getMchId(), createmchBean.getNickName(), false);
			addAgentProductBean.setFreightTemplateId(Integer.parseInt(telId));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			getproductlistBean.setUserId(createmchBean.getMchId());
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(0);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setTitle("God");
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);

			freight_templateWapper templateWapper = new freight_templateWapper();
			templateWapper.updateStatusByKey(Integer.parseInt(telId));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_21() {
		Logger.start(true, "渠道商发布商品，带运费模板，代理商获取商品详细");
		try {
			// CreateFreightTemplateBean createFreightTemplateBean =
			// GodfreightmgrService
			// .initCreateFreightTemplate(vipRootUserId, 1, 2);
			// createFreightTemplateBean.setPolicyModel(1);
			// String telId =
			// GodfreightmgrService.CreateFreightTemplate(createFreightTemplateBean);

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			// addAgentProductBean.setFreightTemplateId(Integer.parseInt(telId));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductListNotsku(getproductlistBean, productListDtoList);

			// freight_templateWapper templateWapper = new
			// freight_templateWapper();
			// templateWapper.updateStatusByKey(Integer.parseInt(telId));

			// 删除模版
			// GodfreightmgrService.DeleteTemplateInfoV2(vipRootUserId,
			// Integer.parseInt(telId), productId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_22() {
		Logger.start(true, "vip渠道->vip1->vip2,vip渠道商发布商品，带运费模板，vip2代理商获取商品详细");
		try {
			// CreateFreightTemplateBean createFreightTemplateBean =
			// GodfreightmgrService
			// .initCreateFreightTemplate(vipRootUserId, 1, 2);
			// String telId =
			// GodfreightmgrService.CreateFreightTemplate(createFreightTemplateBean);

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			// addAgentProductBean.setFreightTemplateId(Integer.parseInt(telId));
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId2, vipAgentUserName2, agentProductId, vipAgentUserId1, false);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			getproductlistBean.setUserId(vipAgentUserId2);
			getproductlistBean.setStatus(1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductListNotsku(getproductlistBean, productListDtoList);
			freight_templateWapper templateWapper = new freight_templateWapper();
			// templateWapper.updateStatusByKey(Integer.parseInt(telId));
			//
			// GodfreightmgrService.DeleteTemplateInfoV2(vipRootUserId,
			// Integer.parseInt(telId), productId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	// 免税店
	private static int userId = AgentUsers.vipRootUserId;
	private static String userName = "韩国免税店";

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_23() {
		Logger.start(true, "渠道商获取含税商品");
		try {

			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);

			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			double tariffRate = 0;
			productListDtoList.forEach(p -> {
				if (p.getProductId().equals(productId)) {
					Logger.verifyEquals(p.getTariffRate(), 0.09, "判断获取的税是否正确");
				}
			});
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_24() {
		Logger.start(true, "vip渠道->vip1->vip2,  vip2和vip1修改sku，修改被忽略");
		try {
			// 渠道商新建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			// addAgentProductBean.setFreightTemplateId(Integer.parseInt(telId));
			int rootsku1 = Integer.parseInt(addAgentProductBean.getCatalogList().get(0).getSku());
			int rootsku2 = Integer.parseInt(addAgentProductBean.getCatalogList().get(1).getSku());
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			// vip1代理渠道商
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			// VIP2代理vip1
			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId2, vipAgentUserName2, agentProductId, vipAgentUserId1, false);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			// 修改渠道商的sku，查询渠道商
			ModifyAgentProductBean mpb = AddAgentProductCallService.initModifyAgentProductBean(productId,
					addAgentProductBean);
			rootsku1 = 777777;
			rootsku2 = 777777;
			mpb.getCatalogList().get(0).setSku("" + rootsku1);
			mpb.getCatalogList().get(1).setSku("" + rootsku2);
			AddAgentProductCallService.modifyAgentProduct(mpb);
			getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setUserId(vipRootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			int sku1 = getproductlistCall.getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList")
					.get(0).getAsJsonObject().getAsJsonArray("catalogList").get(0).getAsJsonObject().get("sku")
					.getAsInt();
			int sku2 = getproductlistCall.getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList")
					.get(0).getAsJsonObject().getAsJsonArray("catalogList").get(1).getAsJsonObject().get("sku")
					.getAsInt();
			Logger.verifyEquals(rootsku1, sku1, "验证渠道商sku是否被修改");
			Logger.verifyEquals(rootsku2, sku2, "验证渠道商sku是否被修改");

			// 查询vip1
			getproductlistBean.setTitle(importAgentProductBean.getTitle());
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			sku1 = getproductlistCall.getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList").get(0)
					.getAsJsonObject().getAsJsonArray("catalogList").get(0).getAsJsonObject().get("sku").getAsInt();
			sku2 = getproductlistCall.getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList").get(0)
					.getAsJsonObject().getAsJsonArray("catalogList").get(1).getAsJsonObject().get("sku").getAsInt();
			Logger.verifyEquals(rootsku1, sku1, "验证vip1sku1是否被修改");
			Logger.verifyEquals(rootsku2, sku2, "验证vip1sku2是否被修改");

			// 查询vip2
			getproductlistBean.setTitle(importAgentProductBean1.getTitle());
			getproductlistBean.setUserId(vipAgentUserId2);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			sku1 = getproductlistCall.getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList").get(0)
					.getAsJsonObject().getAsJsonArray("catalogList").get(0).getAsJsonObject().get("sku").getAsInt();
			sku2 = getproductlistCall.getJsonObject().get("data").getAsJsonObject().getAsJsonArray("productList").get(0)
					.getAsJsonObject().getAsJsonArray("catalogList").get(1).getAsJsonObject().get("sku").getAsInt();
			Logger.verifyEquals(rootsku1, sku1, "验证vip2sku1是否被修改");
			Logger.verifyEquals(rootsku2, sku2, "验证vip2sk2是否被修改");

			// GodfreightmgrService.DeleteTemplateInfoV2(vipRootUserId,
			// Integer.parseInt(telId), productId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_25() {
		Logger.start(true, "代理商获取代理商品，下架商品列表,判断二维码图片");
		try {
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(rootUserId);
			getproductlistBean.setStatus(4);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(0);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			// AgentProductCallService.checkProductList(getproductlistBean,
			// productListDtoList);

			productListDtoList.forEach(p -> {
				Logger.verifyNotEquals("http://pic1.ymatou.com/G01/M00/3F/CD/rBBlD1yTd4WAbU-EAAASgZEqTKo914_1_1_o.png",
						p.getPics().get(0), "生成小程序吗成功");
				Logger.debug(p.getPics().get(0));
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_26() {
		Logger.start(true, "获取含税商品,然后判断二维码图片");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			System.out.println("新生成的商品id为：" + productId);

			Thread.sleep(2000);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			// double tariffRate=0;
			// productListDtoList.forEach(p->{
			// if(p.getProductId().equals(productId)){
			// Logger.verifyEquals(p.getTariffRate(),0.09,"判断获取的税是否正确");
			// }
			// });
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
			productListDtoList.forEach(p -> {
				Logger.verifyNotEquals("http://pic1.ymatou.com/G01/M00/3F/CD/rBBlD1yTd4WAbU-EAAASgZEqTKo914_1_1_o.png",
						p.getPics().get(0), "生成小程序吗成功");
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_27() {
		Logger.start(true, "修改商品的时候，二维码发生变化");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			// 查询二维码
			Thread.sleep(6000);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			String QRCode = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(productId)) {
					QRCode = a.getPics().get(a.getPics().size() - 1);
				}
			}
			// 修改商品
			ModifyAgentProductBean mpb = AddAgentProductCallService.initModifyAgentProductBean(productId,
					addAgentProductBean);
			mpb.setTitle("啊哈哈哈哈哈");
			AddAgentProductCallService.modifyAgentProduct(mpb);
			// 再次查询二维码
			Thread.sleep(6000);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();
			String newCode = "";
			for (ProductListDto a : productListDtoList1) {
				if (a.getProductId().equals(productId)) {
					newCode = a.getPics().get(a.getPics().size() - 1);
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_28() {
		Logger.start(true, "修改代理的时候，二维码全部发生变化");
		try {

			// 创建用户
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
			int newRootUserId = DGUserCallService.UserCreateCall(usercreateBean1);
			String newRootUserName = usercreateBean1.getNickname();
			// 创建代理
			usercreateBean1 = DGUserCallService.initUsercreateBean();
			int newAgentUserId1 = DGUserCallService.UserCreateCall(usercreateBean1);
			String newAgentUserName1 = usercreateBean1.getNickname();

			createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(newRootUserId);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(newRootUserId,
					newAgentUserId1);

			GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));

			// 渠道商新建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(newRootUserId,
					newRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			// new1代理渠道商
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(newAgentUserId1, newAgentUserName1, productId, newRootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setUserId(newRootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");

			List<ProductListDto> rootnewproductList = getproductlistCall.getProductList();

			// 查询new1
			getproductlistBean.setTitle(importAgentProductBean.getTitle());
			getproductlistBean.setUserId(newAgentUserId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> agentnewproductList = getproductlistCall.getProductList();

			// 移除代理
			GodmchManageCallService.InitremovemchForAgent(newRootUserId, newAgentUserId1);

			getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setUserId(newRootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");

			List<ProductListDto> rootnew1productList = getproductlistCall.getProductList();

			// 查询new1
			getproductlistBean.setTitle(importAgentProductBean.getTitle());
			getproductlistBean.setUserId(newAgentUserId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> agentnew1productList = getproductlistCall.getProductList();

			System.out.println("开始判断");
			System.out.println(rootnewproductList);
			System.out.println(rootnew1productList);
			checkPic(rootnewproductList, rootnew1productList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_29() {
		Logger.start(true, "修改商品的主图时，二维码发生变化");
		try {
			userId = 500347139;
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId, userName,
					true);
			addAgentProductBean.setCurrency("CNY");
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			// 查询二维码
			Thread.sleep(3500);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			String QRCode = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(productId)) {
					QRCode = a.getPics().get(a.getPics().size() - 1);
				}
			}
			// 修改商品
			ModifyAgentProductBean mpb = AddAgentProductCallService.initModifyAgentProductBean(productId,
					addAgentProductBean);
			mpb.getPics().set(2, "http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			AddAgentProductCallService.modifyAgentProduct(mpb);
			// 再次查询二维码
			Thread.sleep(3500);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();
			String newCode = "";
			for (ProductListDto a : productListDtoList1) {
				if (a.getProductId().equals(productId)) {
					newCode = a.getPics().get(a.getPics().size() - 1);
				}
			}
			Logger.verifyNotEquals(QRCode, newCode, "二维码会发生变化");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_30() {
		Logger.start(true, "vip渠道->vip1->vip2,渠道商修改主图，渠道商发生变化，代理商不变" + "");
		try {
			// 渠道商新建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			int rootsku1 = Integer.parseInt(addAgentProductBean.getCatalogList().get(0).getSku());
			int rootsku2 = Integer.parseInt(addAgentProductBean.getCatalogList().get(1).getSku());
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			// vip1代理渠道商
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			// VIP2代理vip1
			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId2, vipAgentUserName2, agentProductId, vipAgentUserId1, false);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			Thread.sleep(5000);
			getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setUserId(vipRootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			String oldvip = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(productId)) {
					System.out.println("oldvip:" + a);
					oldvip = a.getPics().get(a.getPics().size() - 1);
				}
			}

			// 查询vip1
			getproductlistBean.setTitle(importAgentProductBean.getTitle());
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");

			productListDtoList = getproductlistCall.getProductList();
			String oldvip1 = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(agentProductId)) {
					System.out.println("oldvip1:" + a);
					oldvip1 = a.getPics().get(0);
				}
			}
			// 查询vip2
			getproductlistBean.setTitle(importAgentProductBean1.getTitle());
			getproductlistBean.setUserId(vipAgentUserId2);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			productListDtoList = getproductlistCall.getProductList();
			String oldvip2 = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(agentProductId1)) {
					System.out.println("oldvip2:" + a);
					oldvip2 = a.getPics().get(0);
				}
			}

			// http://pic1.ymatou.com/G01/M00/1F/6B/rBBlD11nrzCABj2qAAHX3Wt3-lE612_1_1_n_w_o.jpg
			// http://pic1.ymatou.com/G01/M00/1F/6C/rBBlD11nr0KAZti8AAHXza9w4sw726_1_1_n_w_o.jpg
			// http://pic1.ymatou.com/G01/M00/1F/6C/rBBlD11nrzeAfBLxAAHOn2nMCGM472_1_1_n_w_o.jpg
			// http://pic1.ymatou.com/G01/M00/1F/6C/rBBlD11nrzeAfBLxAAHOn2nMCGM472_1_1_n_w_o.jpg
			// http://pic1.ymatou.com/G01/M00/1F/6C/rBBlD11nrzqAHnVZAAHjNBEpHFQ069_1_1_n_w_o.jpg
			// http://pic1.ymatou.com/G01/M00/1F/6C/rBBlD11nrzqAHnVZAAHjNBEpHFQ069_1_1_n_w_o.jpg

			//
			// 修改渠道商的sku，查询渠道商
			ModifyAgentProductBean mpb = AddAgentProductCallService.initModifyAgentProductBean(productId,
					addAgentProductBean);
			//// mpb.getCatalogList().get(0).setSku("666");
			//// mpb.setTitle(mpb.getTitle()+"123");
			// mpb.getPics().set(0,
			//// "http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBl123412341.jpg");
			mpb.getPics().set(1, "http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/r123123123.jpg");
			mpb.getPics().set(2, "http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/66666666.jpg");
			AddAgentProductCallService.modifyAgentProduct(mpb);
			//
			Thread.sleep(5000);

			getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setUserId(vipRootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			productListDtoList = getproductlistCall.getProductList();
			String newvip = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(productId)) {
					System.out.println("newvip:" + a);
					newvip = a.getPics().get(0);
				}
			}

			// 查询vip1
			getproductlistBean.setTitle(importAgentProductBean.getTitle());
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");

			productListDtoList = getproductlistCall.getProductList();
			String newvip1 = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(agentProductId)) {
					System.out.println("newvip1:" + a);
					newvip1 = a.getPics().get(0);
				}
			}
			// 查询vip2
			getproductlistBean.setTitle(importAgentProductBean1.getTitle());
			getproductlistBean.setUserId(vipAgentUserId2);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");

			productListDtoList = getproductlistCall.getProductList();
			String newvip2 = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(agentProductId1)) {
					System.out.println("newvip2:" + a);
					newvip2 = a.getPics().get(0);
				}
			}

			System.out.println(oldvip);
			System.out.println(newvip);
			System.out.println(oldvip1);
			System.out.println(newvip1);
			System.out.println(oldvip2);
			System.out.println(newvip2);

			Logger.verifyNotEquals(oldvip, newvip, "判断渠道商图");
			Logger.verifyEquals(oldvip1, newvip1, "判断代理1图");
			Logger.verifyEquals(oldvip2, newvip2, "判断代理2图");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_31() {
		Logger.start(true, "使用一个，多个模糊词查询标题");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			addAgentProductBean.setTitle("t恤女长袖白色纯棉宽松女装内搭打底衫2019新款秋季上衣初秋ins潮");
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			Thread.sleep(5000);

			// 获取es结果
			EsGodProduct esProduct = checkEsSync(productId);

			// 模糊查询商品列表
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle("秋季");
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();

			// 判断是否查询到了
			Logger.verifyNotEquals(-1, productListDtoList.toString().indexOf(esProduct.getPid()), "模糊搜索没有找到商品");

			// 词汇打乱查询
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle("女装内搭打底衫纯棉袖新款秋季白色宽松2019");
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();

			// 判断是否查询到了
			Logger.verifyNotEquals(-1, productListDtoList1.toString().indexOf(esProduct.getPid()), "模糊搜索没有找到商品");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_32() {
		Logger.start(true, "查询下架商品");
		try {
			// 发布一个下架商品商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			addAgentProductBean.setSaleType(2);
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			Thread.sleep(5000);

			// 获取es结果
			EsGodProduct esProduct = checkEsSync(productId);

			// 查询商品列表
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setStatus(2);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();

			// 判断是否查询到了
			Logger.verifyNotEquals(-1, productListDtoList.toString().indexOf(esProduct.getPid()), "没有查询到刚刚添加的商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_33() {
		Logger.start(true, "查询代理商品");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			// YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
			// ymtCatalogsIWapper.updatestocknumByProductID(0, productId);
			Thread.sleep(3000);
			// 获取es结果
			EsGodProduct esProduct = checkEsSync(agentProductId);
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
			// 判断是否查询到了
			Logger.verifyNotEquals(-1, productListDtoList.toString().indexOf(esProduct.getPid()), "没有查询到刚刚添加的商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_34() {
		Logger.start(true, "判断二维码图片是否在最后一个");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			// 查询二维码
			Thread.sleep(3500);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			String QRCode = "";
			for (ProductListDto a : productListDtoList) {
				if (a.getProductId().equals(productId)) {
					QRCode = a.getPics().get(a.getPics().size() - 1);
				}
			}

			Logger.verifyNotEquals("-1", QRCode.indexOf("shangou"), "判断二维码是否在最后一个");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_35() {
		Logger.start(true, "渠道商发布商品，下面自动继承的代理自动继承,判断进货价是否正确");
		try {
			// 创建两个用户
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_channl = DGUserCallService.UserCreateCall(usercreateBean1);
			usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_agent = DGUserCallService.UserCreateCall(usercreateBean1);
			// 设置渠道商
			createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,
					usercreateBean1.getNickname(), true);
			double price = 200;
			addAgentProductBean.getCatalogList().forEach(a -> {
				a.setDirectPrice(price * 2);
				a.getAgentPriceList().forEach(b -> {
					b.setAgentPrice(price);
				});
			});
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(userId_channl,
					productId);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 渠道商创建一个邀请码，出来一个自动继承的代理商、自动继承渠道商刚才的商品
			CreateCodeBean createbean = GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl);
			createbean.setAgentModel(2);// 自动继承
			CreateCodeCall CreateCodeCall = GodmchManageCallService.createCodeCall(createbean);
			List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(userId_channl,
					userId_agent); //
			createmchList.get(0).setCode(CreateCodeCall.getCode());
			GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));
			Thread.sleep(5000);
			// 渠道商查询
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_channl);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			JsonArray asJsonArray = getproductlistCall.getJsonObject().getAsJsonObject("data")
					.getAsJsonArray("productList").get(0).getAsJsonObject().getAsJsonArray("catalogList");
			// 代理商查询
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_agent);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			JsonArray asJsonArray1 = getproductlistCall.getJsonObject().getAsJsonObject("data")
					.getAsJsonArray("productList").get(0).getAsJsonObject().getAsJsonArray("catalogList");
			// 判断代理提货价 与渠道商提货价
			asJsonArray.forEach(a -> {
				double asDouble = a.getAsJsonObject().get("directPrice").getAsDouble();
				double asDouble2 = a.getAsJsonObject().get("agentPrice").getAsDouble();
				Logger.verifyEquals(price * 2, asDouble, "直销价");
				Logger.verifyEquals(0.0, asDouble2, "渠道商提货价");
			});
			asJsonArray1.forEach(a -> {
				double asDouble = a.getAsJsonObject().get("directPrice").getAsDouble();
				double asDouble2 = a.getAsJsonObject().get("agentPrice").getAsDouble();
				Logger.verifyEquals(price * 2, asDouble, "直销价");
				Logger.verifyEquals(price, asDouble2, "代理商提货价");
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_36() {
		Logger.start(true, "渠道商发布商品，下面自动继承的代理自动继承,判断进货价是否正确");
		try {

			// 创建两个用户
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_channl = DGUserCallService.UserCreateCall(usercreateBean1);
			usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_agent = DGUserCallService.UserCreateCall(usercreateBean1);
			// 设置渠道商
			createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,
					usercreateBean1.getNickname(), true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			// 渠道商创建一个邀请码，出来一个自动继承的代理商、自动继承渠道商刚才的商品
			CreateCodeBean createbean = GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl);
			createbean.setAgentModel(2);// 自动继承
			CreateCodeCall CreateCodeCall = GodmchManageCallService.createCodeCall(createbean);
			List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(userId_channl,
					userId_agent); //
			createmchList.get(0).setCode(CreateCodeCall.getCode());
			GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));
			Thread.sleep(5000);

			// 渠道商发布商品

			// 查询渠道商
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_channl);
			// getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();

			Thread.sleep(5000);
			// 查询代理商
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_agent);
			// getproductlistBean.setTitle(addAgentProductBean.getTitle());
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();

			AgentProductPo selectAgentProductByProductId = ymtProductsIWapper.selectAgentProductByProductId(productId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_37() {
		Logger.start(true, "白名单用户支持9张图，我的商品列表增加productIdList参数");
		try {
			userId = 500030275;
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);

			List<String> picList = new ArrayList<>();

			for (int i = 0; i < 9; i++) {
				picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32---------" + i
						+ "----------.jpg");
			}

			addAgentProductBean.setPics(picList);
			addAgentProductBean.setCurrency("CNY");
			// addAgentProductBean.setMarketCurrency("CHY");

			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			// 查询二维码
			Thread.sleep(3500);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle(null);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			System.out.println(productListDtoList);

			for (ProductListDto productListDto : productListDtoList) {
				if (productListDto.getProductId().equals(productId)) {
					Logger.verifyEquals(10, productListDto.getPics().size(), "九张图+一个二维码");
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_38() {
		Logger.start(true, "商品列表使用productIds + userId作为条件查询，");
		try {
			// 发布商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV3(userId, userName,
					true);
			String productId = AddAgentProductCallService.AddAgentProduct1(addAgentProductBean);
			// 查询二维码
			Thread.sleep(3500);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId);
			getproductlistBean.setTitle("这个不管输入什么，都会忽略。所以随便输入一些");
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			System.out.println(productListDtoList);
			String a = "";
			for (ProductListDto productListDto : productListDtoList) {
				if (productListDto.getProductId().equals(productId)) {
					a = productListDto.getProductId();
				}
			}

			Logger.verifyEquals(productId, a, "根据商品id列表productid查询到了");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_39() {
		Logger.start(true, "代理水印开--非继承性代理查询水印");
		try {

			int userId_channl = 500275675;
			int userId_agent = 500275676;
			AddAgentProductBean sellerProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,
					"666666", true);
			// 提交发布商品
			// 提交发布商品
			String f1 = System.getProperty("user.dir") + File.separator + "resource" + File.separator + "Penguins.jpg";
			FontImage.addWaterMark(f1, f1, Arrays.asList("测试" + TestDataManager.getRandomNum(2)),
					new Font("blod", 1, 20), Color.BLACK,"png");
			String picUrl = TestDataManager.UploadFile(f1);
			sellerProductBean.getPics().set(2, picUrl);
			String productId = AddAgentProductCallService.AddAgentProduct(sellerProductBean);
			Thread.sleep(5000);

			ImportAgentProductBean AgentProductBean = AddAgentProductCallService.initImportAgentProduct(userId_agent,
					"777777", productId, userId_channl, false);

			String productId1 = AddAgentProductCallService.ImportAgentProduct(AgentProductBean);

			Thread.sleep(5000);
			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_channl);
			getproductlistBean.setTitle("这个不管输入什么，都会忽略。所以随便输入一些");
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();

			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_agent);
			getproductlistBean.setTitle("这个不管输入什么，都会忽略。所以随便输入一些");
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setProductIds(Arrays.asList(productId1));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_40() {
		Logger.start(true, "代理水印关--非继承性代理查询水印");
		try {

			int userId_channl = 500275675;
			int userId_agent = 500275676;
			AddAgentProductBean sellerProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,
					"666666", true);
			// 提交发布商品
			String productId = AddAgentProductCallService.AddAgentProduct(sellerProductBean);
			Thread.sleep(5000);

			ImportAgentProductBean AgentProductBean = AddAgentProductCallService.initImportAgentProduct(userId_agent,
					"777777", productId, userId_channl, false);

			String productId1 = AddAgentProductCallService.ImportAgentProduct(AgentProductBean);

			Thread.sleep(5000);

			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_channl);
			getproductlistBean.setTitle("这个不管输入什么，都会忽略。所以随便输入一些");
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();

			getproductlistBean = AddAgentProductCallService.initGetProductListBean(userId_agent);
			getproductlistBean.setTitle("这个不管输入什么，都会忽略。所以随便输入一些");
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setProductIds(Arrays.asList(productId1));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_GetProductList_41() {
		Logger.start(true, "查询代理商品，判断代理价列表");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			// YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
			// ymtCatalogsIWapper.updatestocknumByProductID(0, productId);
			Thread.sleep(3000);
			// 获取es结果
			EsGodProduct esProduct = checkEsSync(agentProductId);
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setAgentType(1);
			getproductlistBean.setStatus(1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			// 判断是否查询到了
			Logger.verifyNotEquals(-1, productListDtoList.toString().indexOf(esProduct.getPid()), "没有查询到刚刚添加的商品");
			// Logger.verifyNotEquals(0,productListDtoList.get(0).getAgentPriceList().size(),
			// "查询到了代理商品价格列表");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_42() {
		Logger.start(true, "渠道商查询商品，判断虚拟库存");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			// 获取es结果
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			// 判断是否查询到了和虚拟库存真实库存
			Logger.verifyNotEquals(0, productListDtoList.get(0).getCatalogList().size(), "查询到了商品");
			Logger.verifyEquals(70, productListDtoList.get(0).getCatalogList().get(0).getStock(), "总库存查询");
			Logger.verifyEquals(40, productListDtoList.get(0).getCatalogList().get(0).getRealStock(), "真实库存查询");
			Logger.verifyEquals(30, productListDtoList.get(0).getCatalogList().get(0).getVirtualStock(), "虚拟库存查询");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_43() {
		Logger.start(true, "代理查询商品，判断虚拟库存");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setVirtualStock(30);
			addAgentProductBean.getCatalogList().get(0).setStock(40);
			String RootproductId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, RootproductId, vipRootUserId, false);
			String productId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			Thread.sleep(3000);
			// 获取es结果
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setProductIds(Arrays.asList(productId));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			// 判断是否查询到了和虚拟库存真实库存
			Logger.verifyNotEquals(0, productListDtoList.get(0).getCatalogList().size(), "查询到了商品");
			Logger.verifyEquals(70, productListDtoList.get(0).getCatalogList().get(0).getStock(), "总库存查询");
			Logger.verifyEquals(40, productListDtoList.get(0).getCatalogList().get(0).getRealStock(), "真实库存查询");
			Logger.verifyEquals(30, productListDtoList.get(0).getCatalogList().get(0).getVirtualStock(), "虚拟库存查询");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_44() {
		Logger.start(true, "代理商获取代理商品，根据品牌id查询");
		try {
			
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setBrandId(AddAgentProductCallService.BrandId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_45() {
		Logger.start(true, "代理商获取代理商品，根据分类id查询");
		try {
			getproductlistBean.setUserId(vipAgentUserId1);
			getproductlistBean.setBrandId(1001);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			AgentProductCallService.checkProductList(getproductlistBean, productListDtoList);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_46() {
		Logger.start(true, "设置了自动加价的代理商查询商品，验证标识");
		try {
			int rootUserId = 501475646;
			int agentUserId = 501475647;
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId, "",
					true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			getproductlistBean.setUserId(agentUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(e -> {
				if (e.getProductId() == productId) {
					Logger.verifyEquals(e.getAutoMarkupStatus(), 1, "验证自动打标");
				}
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_47() {
		Logger.start(true, "没有设置了自动加价的代理商查询商品，验证标识");
		try {
			getproductlistBean.setUserId(agentUserId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(e -> {
				Logger.verifyEquals(e.getAutoMarkupStatus(), -1, "验证自动打标");
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_48() {
		Logger.start(true, "VIP二级代理会向下铺货");
		try {
			int vipRootId = 500781768;
			int vipAgentId1 = 500781769;
			int vipAgentId2 = 500781770;

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootId, "",
					true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			Thread.sleep(5000);
			// 查到代理商的商品id
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream()
					.filter(x -> x.getAction() == 0).filter(x -> x.getUserId() == vipAgentId1)
					.collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			String agentProductId1 = ap.get(0).getProductId();

			// 查询二级代理商的商品id
			List<AgentProductPo> ap1 = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream()
					.filter(x -> x.getAction() == 0).filter(x -> x.getUserId() == vipAgentId2)
					.collect(Collectors.toList());
			Logger.debug("ap1:" + FormatUtil.beanToGSONString(ap1));
			Logger.verifyEquals(ap1.size(), 1, "二级代理不会向下铺货");


		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_49() {
		Logger.start(true, "渠道商查看自己的商品详情，当商品开关与是商户开关都开启时，自提开关开启");
		try {
			int rootUserId = 501465799;
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					"", true);
			addAgentProductBean.setCollectionGoods(true);
			addAgentProductBean.setExpressDelivery(true);
			String RootproductId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			Thread.sleep(3000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productList = getproductlistCall.getProductList();
			productList.forEach(b->{
				if(b.getProductId().equals(RootproductId)){
					Logger.comment("匹配的为："+b);
					Logger.verifyEquals(b.getExpressDelivery(), true, "验证快递配送方式字段");
					Logger.verifyEquals(b.getCollectionGoods(), true, "验证自提配送方式字段");
				}
			});
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_50() {
		Logger.start(true, "渠道商查看自己的商品详情，当商品开关开区，商户开关关闭时，自提开关关闭");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			addAgentProductBean.setCollectionGoods(true);
			addAgentProductBean.setExpressDelivery(true);
			String RootproductId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(3000);
			getproductlistBean.setUserId(vipRootUserId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productList = getproductlistCall.getProductList();
			productList.forEach(b->{
				if(b.getProductId().equals(RootproductId)){
					Logger.comment("匹配的为："+b);
					Logger.verifyEquals(b.getExpressDelivery(), true, "验证快递配送方式字段");
					Logger.verifyEquals(b.getCollectionGoods(), false, "验证自提配送方式字段");
				}
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_51() {
		Logger.start(true, "VIP二级代理会向下铺货，判断自动加价标志");
		try {
			int vipRootId = 500781768;
			int vipAgentId1 = 500781769;
			int vipAgentId2 = 500781770;

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootId, "",
					true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			Thread.sleep(5000);
			// 查到代理商的商品id
			List<AgentProductPo> ap = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream()
					.filter(x -> x.getAction() == 0).filter(x -> x.getUserId() == vipAgentId1)
					.collect(Collectors.toList());
			Logger.debug("ap:" + FormatUtil.beanToGSONString(ap));
			String agentProductId1 = ap.get(0).getProductId();

			// 查询二级代理商的商品id
			List<AgentProductPo> ap1 = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream()
					.filter(x -> x.getAction() == 0).filter(x -> x.getUserId() == vipAgentId2)
					.collect(Collectors.toList());
			Logger.debug("ap1:" + FormatUtil.beanToGSONString(ap1));
			Logger.verifyEquals(ap1.size(), 1, "二级代理不会向下铺货");
			
			getproductlistBean.setUserId(vipAgentId1);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(e -> {
				if (e.getProductId().equals(ap.get(0).getProductId())) {
					Logger.verifyEquals(e.getAutoMarkupStatus(), 1, "验证自动打标");
				}
			});
			
			getproductlistBean.setUserId(vipAgentId2);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();
			productListDtoList1.forEach(e -> {
				if (e.getProductId().equals(ap1.get(0).getProductId())) {
					Logger.verifyEquals(e.getAutoMarkupStatus(), 1, "验证自动打标");
				}
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_52() {
		Logger.start(true, "获取商品列表，根据备注查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, false);
			String b="remark"+TestDataManager.getRandomNum(6);
			addAgentProductBean.setRemark(b);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setRemark(b);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.size(), 1, "验证size");
			Logger.verifyEquals(productListDtoList.get(0).getRemark(),b, "验证备注");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_53() {
		Logger.start(true, "获取商品列表，根据仓库Id查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			createDepotBean bean=GodmchManageCallService.createDepot(rootUserId);
            List<mch_depot_info> selectDepotByDepotTitle = GodmchManageCallService.SelectDepotByDepotTitle(bean.getDepotTitle());
            addAgentProductBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.size(), 1, "验证size");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_54() {
		Logger.start(true, "获取商品列表，根据物流类型查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setDeliveryTypes(Arrays.asList(999));
			
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),productId, "验证productId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_55() {
		Logger.start(true, "获取商品列表，根据最小最大库存查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setMinStock(10);
			getproductlistBean.setMaxStock(400);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),productId, "验证productId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_56() {
		Logger.start(true, "获取商品列表，根据SKUID查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setSkuIds(addAgentProductBean.getCatalogList().get(0).getSku());
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),productId, "验证productId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_57() {
		Logger.start(true, "获取商品列表，查询未露出");
		try {
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setStatus(5);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),productId, "验证productId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_58() {
		Logger.start(true, "获取商品列表，增加了条形码");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			List<String> barCodes = Arrays.asList("Hello"+TestDataManager.getRandomNum(6),"Hello"+TestDataManager.getRandomNum(6));
			addAgentProductBean.getCatalogList().get(0).setBarcode(barCodes.get(0));;
			addAgentProductBean.getCatalogList().get(1).setBarcode(barCodes.get(1));;
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setBarcodes(barCodes.get(0));
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),productId, "验证productId");
			
//			Logger.verifyEquals(productListDtoList.get(0).getCatalogList().get(0).getBarcode(),productId, "验证productId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_59() {
		Logger.start(true, "商户-》分销小店，条件筛选不匹配查不到，不会自动铺货、如果匹配就能查到");
		try {
			
			int MchId=501163195;
			int AgentId = 501163196;
			
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			SaveSelectionConditionBean initSaveSelectionCondition = AddAgentProductCallService.InitSaveSelectionCondition(MchId, AgentId, 1);
			initSaveSelectionCondition.setBrandIdList(Arrays.asList(666));
			AddAgentProductCallService.SaveSelectionCondition(initSaveSelectionCondition);
			
			AddAgentProductBean addAgentProductBean1 = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId1 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean1);
			
			
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.size(),0, "验证productId");
			
			Thread.sleep(3000);
			
			initSaveSelectionCondition = AddAgentProductCallService.InitSaveSelectionCondition(MchId, AgentId, 0);
			AddAgentProductCallService.SaveSelectionCondition(initSaveSelectionCondition);
			
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList1 = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList1.get(0).getProductId(),productId, "验证productId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_60() {
		Logger.start(true, "商户-》代理，条件筛选不匹配查不到，不会自动铺货、然后删除商品");
		try {
			
			Integer MchId = GodmchManageCallService.CreateGodMch();
            Integer agenttype=GodmchManageCallService.getAgentType(MchId, 1);
            Integer AgentId = GodmchManageCallService.getAgentMchId(MchId, agenttype);
            //添加导入商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean initImportAgentProduct = AddAgentProductCallService.initImportAgentProduct(AgentId, "", productId, MchId, false);
			String AgentProductId = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct);
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList2 = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList2.get(0).getProductId(),AgentProductId, "验证productId");
			
			
			
			SaveSelectionConditionBean initSaveSelectionCondition = AddAgentProductCallService.InitSaveSelectionCondition(MchId, AgentId, 1);
			initSaveSelectionCondition.setBrandIdList(Arrays.asList(666));
			AddAgentProductCallService.SaveSelectionCondition(initSaveSelectionCondition);
			
			
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(0,productListDtoList.size(), "验证productId");
			
			
			// 查询二级代理商的商品id
			List<AgentProductPo> ap1 = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream()
								.filter(x -> x.getUserId() == AgentId)
								.collect(Collectors.toList());
			Logger.verifyEquals(-1, ap1.get(0).getAction(), "筛选后删除商品");
						
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_61() {
		Logger.start(true, "商户-》代理-》分销小店，上级设置筛选之后，分销小店也会移除");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			GodmchManageCallService.SetVip(MchId);
			Integer AgentId = GodmchManageCallService.CreateAgent(MchId);
			Integer StoreId = GodmchManageCallService.CreateStoresByAgent(MchId,AgentId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(AgentId,"",productId,MchId,false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			Thread.sleep(5000);
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(agentProductId,StoreId, AgentId, 20);
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(StoreId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList2 = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList2.get(0).getProductId(),agentProductId, "验证productId");
			
			SaveSelectionConditionBean initSaveSelectionCondition = AddAgentProductCallService.InitSaveSelectionCondition(MchId, AgentId, 1);
			initSaveSelectionCondition.setBrandIdList(Arrays.asList(666));
			AddAgentProductCallService.SaveSelectionCondition(initSaveSelectionCondition);
			
			Thread.sleep(3000);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
//			getproductlistCall.getJsonObject().getAsJsonObject("data").getAsJsonArray("productList")
			Logger.verifyEquals(0,productListDtoList.size(), "验证productId");
			
			// 查询二级代理商的商品id
			List<AgentProductPo> ap1 = ymtProductsIWapper.selectAgentProductByRootProductId(productId).stream()
								.filter(x -> x.getUserId() == AgentId)
								.collect(Collectors.toList());
			Logger.verifyEquals(-2, ap1.get(0).getAction(), "筛选后删除商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_62() {
		Logger.start(true, "商户-》代理，三种情况。查询自己高于建议零售价的商品");
		try {
			Integer MchId = GodmchManageCallService.CreateGodMch();
            Integer agenttype=GodmchManageCallService.getAgentType(MchId, 1);
            Integer AgentId = GodmchManageCallService.getAgentMchId(MchId, agenttype);
            //添加导入商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
//			addAgentProductBean.getCatalogList().get(0).setMarketAmount(300);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean initImportAgentProduct = AddAgentProductCallService.initImportAgentProduct(AgentId, "", productId, MchId, false);
			initImportAgentProduct.getCatalogList().get(0).setDirectPrice(addAgentProductBean.getCatalogList().get(0).getDirectPrice()+1);
			initImportAgentProduct.getCatalogList().get(1).setDirectPrice(addAgentProductBean.getCatalogList().get(1).getDirectPrice()+1);
			String AgentProductId = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct);
			
			 //添加导入商品
			AddAgentProductBean addAgentProductBean2 = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
//			addAgentProductBean2.getCatalogList().get(0).setMarketAmount(300);
			String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean2);
			ImportAgentProductBean initImportAgentProduct2 = AddAgentProductCallService.initImportAgentProduct(AgentId, "", productId2, MchId, false);
			initImportAgentProduct2.getCatalogList().get(0).setDirectPrice(addAgentProductBean2.getCatalogList().get(0).getDirectPrice()-1);
			initImportAgentProduct2.getCatalogList().get(1).setDirectPrice(addAgentProductBean2.getCatalogList().get(1).getDirectPrice()-1);
			String AgentProductId2 = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct2);
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPriceThanAdvice(true);
			getproductlistBean.setPriceLessAdvice(false);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(1,productListDtoList.size(), "验证查询高于零售价商品");
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),AgentProductId, "验证高于零售价");
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPriceThanAdvice(false);
			getproductlistBean.setPriceLessAdvice(true);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList2 = getproductlistCall.getProductList();
			Logger.verifyEquals(1,productListDtoList2.size(), "验证查询低于零售价商品");
			Logger.verifyEquals(productListDtoList2.get(0).getProductId(),AgentProductId2, "验证低于零售价");
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPriceThanAdvice(true);
			getproductlistBean.setPriceLessAdvice(true);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList3 = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList3.size(), "验证查询低于零售价商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_63() {
		Logger.start(true, "商户-》代理，三种情况。只有一个规格满足的时候，也会查出这个商品");
		try {
			Integer MchId = GodmchManageCallService.CreateGodMch();
            Integer agenttype=GodmchManageCallService.getAgentType(MchId, 1);
            Integer AgentId = GodmchManageCallService.getAgentMchId(MchId, agenttype);
            //添加导入商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
//			addAgentProductBean.getCatalogList().get(0).setMarketAmount(300);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean initImportAgentProduct = AddAgentProductCallService.initImportAgentProduct(AgentId, "", productId, MchId, false);
			initImportAgentProduct.getCatalogList().get(0).setDirectPrice(addAgentProductBean.getCatalogList().get(0).getDirectPrice()+1);
			initImportAgentProduct.getCatalogList().get(1).setDirectPrice(addAgentProductBean.getCatalogList().get(1).getDirectPrice()-1);
			String AgentProductId = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct);
			
			 //添加导入商品
			AddAgentProductBean addAgentProductBean2 = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
//			addAgentProductBean2.getCatalogList().get(0).setMarketAmount(300);
			String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean2);
			ImportAgentProductBean initImportAgentProduct2 = AddAgentProductCallService.initImportAgentProduct(AgentId, "", productId2, MchId, false);
			initImportAgentProduct2.getCatalogList().get(0).setDirectPrice(addAgentProductBean2.getCatalogList().get(0).getDirectPrice()-1);
			initImportAgentProduct2.getCatalogList().get(1).setDirectPrice(addAgentProductBean2.getCatalogList().get(1).getDirectPrice()+1);
			String AgentProductId2 = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct2);
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPriceThanAdvice(true);
			getproductlistBean.setPriceLessAdvice(false);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList.size(), "验证查询高于零售价商品");
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPriceThanAdvice(false);
			getproductlistBean.setPriceLessAdvice(true);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList2 = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList2.size(), "验证查询低于零售价商品");
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setPriceThanAdvice(true);
			getproductlistBean.setPriceLessAdvice(true);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList3 = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList3.size(), "验证查询低于零售价商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_64() {
		Logger.start(true, "查看商品列表，根据品牌筛选");
		try {
			Integer MchId = GodmchManageCallService.CreateGodMch();
            Integer agenttype=GodmchManageCallService.getAgentType(MchId, 1);
            Integer AgentId = GodmchManageCallService.getAgentMchId(MchId, agenttype);
            createDepotBean bean=GodmchManageCallService.createDepot(MchId);
			List<mch_depot_info> selectDepotByDepotTitle = GodmchManageCallService.SelectDepotByDepotTitle(bean.getDepotTitle());

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			addAgentProductBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			AddAgentProductBean addAgentProductBean1 = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			addAgentProductBean1.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
			String productId1 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean1);
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setBrandId(addAgentProductBean.getBrandId());
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList.size(), "验证查询高于零售价商品");
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setCategoryIdList(Arrays.asList(1002));
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList2 = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList2.size(), "验证查询低于零售价商品");
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(AgentId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistBean.setDepotIdList(Arrays.asList(addAgentProductBean.getDepotId()));
			getproductlistBean.setPriceLessAdvice(true);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList3 = getproductlistCall.getProductList();
			Logger.verifyEquals(2,productListDtoList3.size(), "验证查询低于零售价商品");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_65() {
		Logger.start(true, "查看商品列表，查询加价规则");
		try {
			Integer mchId = GodmchManageCallService.CreateGodMch();
            Integer agenttype=GodmchManageCallService.getAgentType(mchId, 1);
            Integer agent_mchId = GodmchManageCallService.getAgentMchId(mchId, agenttype);
            
            createDepotBean bean=GodmchManageCallService.createDepot(mchId);
            List<mch_depot_info> selectDepotByDepotTitle = GodmchManageCallService.SelectDepotByDepotTitle(bean.getDepotTitle());
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId, "", true);
            addAgentProductBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
            
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agent_mchId,"",productId,mchId,false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			Thread.sleep(5000);
			setConditionMarkupConfigBean setConditionMarkupConfigBean = GodmchManageCallService.initDefSetConditionMarkupConfig(agent_mchId, mchId, 1, addAgentProductBean, 1);
			setConditionMarkupConfigBean.setRefreshProduct(true);
            GodmchManageCallService.SetConditionMarkupConfigCall(setConditionMarkupConfigBean);
			
			Thread.sleep(2000);
			getproductlistBean.setUserId(agent_mchId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setAgentType(-1);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			productListDtoList.forEach(b->{
				Logger.verifyEquals(1, b.getAutoMarkupStatus(), "验证加价配置");
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_GetProductList_66() {
		Logger.start(true, "查看商品列表，根据最大最小价格查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			addAgentProductBean.getCatalogList().get(0).setDirectPrice(353.1);
			addAgentProductBean.getCatalogList().get(1).setDirectPrice(354.9);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setMinPrice(353);
			getproductlistBean.setMaxPrice(355);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			List<ProductListDto> productListDtoList = getproductlistCall.getProductList();
			Logger.verifyEquals(productListDtoList.get(0).getProductId(),productId, "验证productId");
		
			getproductlistBean.setUserId(rootUserId);
			getproductlistBean.setPageIndex(1);
			getproductlistBean.setPageSize(10);
			getproductlistBean.setMinPrice(351);
			getproductlistBean.setMaxPrice(352);
			getproductlistCall.setData(getproductlistBean);
			getproductlistCall.callService();
			Logger.verifyEquals("200", getproductlistCall.getString("code"), "验证code");
			Logger.verifyEquals(0,getproductlistCall.getProductList().size(), "验证productId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	

	public static EsGodProduct checkEsSync(String productId) {
		try {// 查询es，判断同步
			ESsearchBean bean = new ESsearchBean();
			ESGodsearchCall call = new ESGodsearchCall();
			bean.setProductId("pid:" + productId);
			call.setData(bean);
			call.callService();
			EsGodProduct esProduct = call.getEsProduct();
			Logger.verifyNotNull(call.getJsonObject().getAsJsonObject("hits").getAsJsonArray("hits"), "判断查询的是不是nulll");
			Logger.verifyEquals(esProduct.getPid(), productId, "判断商品id");
			return esProduct;

		} catch (Exception e) {
			return null;
		}
	}

	public static void checkPic(List<ProductListDto> agent1, List<ProductListDto> agent2) {
		for (ProductListDto product : agent1) {
			String productId = product.getProductId();

			for (ProductListDto product2 : agent2) {
				if (product2.getProductId().equals(productId)) {
					Logger.verifyEquals(product.getPics().get(0), product2.getPics().get(0), "判断移除代理后的二维码是否有变化");
				}
			}
		}
	}

}